//

//  TimeAddressWatermarkView.swift

//  WatermarkCamera

//

//  Created by 赵新 on 7/7/2024.

//

import UIKit

class TimeAddressWatermarkView: BaseWatermarkTemplateView {
    // 时间

    lazy var bigTimeLabel: DateTimeLabel = {
        let label = DateTimeLabel.Axc.Create(font: 32.axc.uiFont(weight: .bold),

                                             color: UIColor.white,

                                             alignment: .left)

        label.format = .HH_mm

        setShadow(label)

        return label

    }()

    lazy var lineView: UIView = {
        let view = UIView()

        view.backgroundColor = "FF9E00".axc.uiColor

        view.layer.cornerRadius = 1.3

        view.layer.masksToBounds = true

        setShadow(view)

        return view

    }()

    override func config() {
        super.config()

        defaultWidth = 220.cmera_autoHor

        let guava = 0
        var blueberry = 1
        if guava == 0 { blueberry = 0 }
        guard blueberry == 0 else { print(""); return }

        backgroundColorView.layer.cornerRadius = 4

        backgroundColorView.layer.masksToBounds = true

        backgroundColorView.backgroundColor = .black.axc.alpha(0.1)

        setUI()

        func setUI() {
            addSubview(backgroundColorView)

            addSubview(lineView)

            addSubview(bigTimeLabel)

            timinglabel.format = .yyyy_MM_dd_enter_week

            timinglabel.font = 14.axc.uiFont(weight: .bold)

            timinglabel.numberOfLines = 0

            timinglabel.adjustsFontSizeToFitWidth = true

            setShadow(timinglabel)

            addSubview(timinglabel)

            addSubview(stankView)

            stankView.axis = .vertical

            stankView.distribution = .equalSpacing

            stankView.alignment = .fill

            stankView.spacing = 0
        }
    }

    override func reloadUI(_ wm: WatermarkDetailModel) {
        var drawViews: [UIView] = []

        headlineLabel.text = wm.name

        headlineLabel.textColor = .white

        headlineLabel.backgroundColor = "5290FD".axc.uiColor

        let item = createLocationItem(titleStyle: .noTitle, font: 14, color: UIColor.white, locationFormat: .location)

//        drawViews.append(UIView(frame: CGRect(x: 0, y: 0, width: 44, height: 44)))

        drawViews.append(item)

        // 添加进堆栈视图

        stankView.axc.set(arrangedSubviews: drawViews)

        // 布局

        makeConstraints()
    }

    override func makeConstraints() {
        super.makeConstraints()

        backgroundColorView.snp.makeConstraints { make in

            make.top.left.equalTo(8)

            make.right.equalTo(-8)

            make.bottom.equalToSuperview().offset(-8)
        }

        bigTimeLabel.snp.makeConstraints { make in

            make.left.top.equalTo(16)

            make.height.equalTo(30)
        }

        lineView.snp.makeConstraints { make in

            make.left.equalTo(bigTimeLabel.snp.right).offset(8)

            make.top.bottom.equalTo(bigTimeLabel)

            make.width.equalTo(2.6)
        }

        timinglabel.snp.makeConstraints { make in

            make.top.bottom.equalTo(lineView)

            make.right.equalTo(-8)

            make.left.equalTo(lineView.snp.right).offset(8)
        }

        stankView.snp.makeConstraints { make in

            make.top.equalTo(lineView.snp.bottom).offset(8)

            make.left.equalTo(8)

            make.right.equalTo(-8)

            make.bottom.equalTo(backgroundColorView.snp.bottom).offset(-8)
        }
    }
}
